package com.zhxh.nzpos.goods;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;

import com.zhxh.nzpos.BaseActivity;
import com.zhxh.nzpos.R;
import com.zhxh.nzpos.dao.SelloutDao;
import com.zhxh.nzpos.utils.ViewUtil;

/**
 * 商品退回
 * 
 * @author wangzt
 *
 */
public class GoodsReturnActivity extends BaseActivity {

	private SelloutDao selloutDao;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goods_return);
        initViews();
    }
	
	public void initViews() {
		selloutDao = new SelloutDao(getApplicationContext());
		
		final EditText orderET = (EditText) findViewById(R.id.goods_return_order_et);
		ImageView okBtn = (ImageView) findViewById(R.id.goods_return_ok_btn);
		okBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Editable et = orderET.getText();
				if (et != null) {
					String orderId = et.toString();
					if (!TextUtils.isEmpty(orderId)) {
						if (selloutDao.returnGoods(orderId)) {
							ViewUtil.makeToast(getApplicationContext(), "退货成功");
							finish();
						} else {
							ViewUtil.makeToast(getApplicationContext(), "退货失败");
						}
					}
				}
			}
		});
		
		ImageView cancelBtn = (ImageView) findViewById(R.id.goods_return_cancel_btn);
		cancelBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				finish();
			}
		});
	}
	
	
}
